<?php

class PackageBase
{
    /**
     * 更新-随机数
     */
    public function upRandom(){
        $paramsObj=paramsObj();
        $paramsObj->params=array(
            'op' => 'random',
            'pid' => '4',
        );
        $setting=new \app\logic\api\L_setting($paramsObj);
        $checkResult=$setting->store($paramsObj);
        if($checkResult["error_no"]){
            return false;
        }
        return true;
    }

    /**
     * 初始化分类
     */
    public function init_category(){
        $checkResult=app("L_Admin_category")->init_category();
        if($checkResult["error_no"]){
            return false;
        }
        return true;
    }

    /**
     * 更换信息
     */
    public function changeInfo(){
        //替换rbac_nav表
        $condition = array();
        $condition[] = array(
            "id", ">", 0
        );
        $data=array();
        $data["plugins"]=Db()->raw("REPLACE(plugins, 'ltcms', 'yifang')");
        Db()->tb_name("rbac_nav")->where($condition)->data($data)->update();

        $condition = array();
        $condition[] = array(
            "id", ">", 0
        );
        $data=array();
        $data["right"]=Db()->raw("REPLACE(`right`, 'ltcms', 'yifang')");
        $data["route"]=Db()->raw("REPLACE(`route`, 'ltcms', 'yifang')");
        $data["plugins"]=Db()->raw("REPLACE(`plugins`, 'ltcms', 'yifang')");
        Db()->tb_name("rbac_node")->where($condition)->data($data)->update();

        //替换module表
        $condition = array();
        $condition[] = array(
            "id", ">", 0
        );
        $data=array();
        $data["plugins"]=Db()->raw("REPLACE(plugins, 'ltcms', 'yifang')");
        Db()->tb_name("module")->where($condition)->data($data)->update();
        return true;
    }
}